const timeline = this.getApiPage().getApiWidgetByAliasName('timelineVertical')?.widgetObj;
const variables = this.pageObj.getVariables();
const prefix = variables.find(v => v.name === "environmentType")?.value;
let params = variables.find(v => v.name === "screen_params")?.value;
const selfObj = this.widgetObj;
const requestGet = (url) => {
    const headers = { "Content-Type": "application/json" }
    return fetch(url, { headers }).then(res => res.json())
};

try {
    params = JSON.parse(params)
} catch (e) {
    console.error(e)
}
console.log(this);

const requestDict = (dictclassCode) => (
    requestGet(`/${prefix}Basics/basics-main/system/dictInfo/list?dictclassCode=${dictclassCode}`).then(({ success, result }) => {
        console.log({ success, result })
        if (success && result && Array.isArray(result.rows)) return result.rows.map(item => ({
            ...item, name: item.dictName, value: item.dataValue,
        }))
    })
)
// 获取当前演练人员列表
const requestPerson = (eventId) => (
    requestGet(`/${prefix}SummaryAssessmentSV/emergencyRecord/recordFilterCriteria?eventId=${eventId}`).then(({ success, result }) => {
        console.log(this, { success, result });
        if (success && result && Array.isArray(result.personList)) return result.personList.map(item => ({
            name: item, value: item,
        }))
    })
)
function loadDict() {
    // 成员
    requestPerson(params.id).then((result) => {
        if (result) selfObj.asyncSelectOptions('personName', result);
    })
    // 所有时间
    requestDict('event_time_scope').then((result) => {
        if (result) selfObj.asyncSelectOptions('timeScope', result)
    })
}

// 加载数据字典
loadDict()



